package com.jotta.client.data;

import java.util.ArrayList;

import com.jotta.client.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Gallery.LayoutParams;

public class ImageAdapter extends BaseAdapter {
	private Context mContext;

	private ArrayList<PictureInfo> picturesInfo;

	public ImageAdapter(Context c, ArrayList<PictureInfo> infos) {
		mContext = c;
		picturesInfo = infos;
	}

	public int getCount() {
		return picturesInfo.size();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView i = new ImageView(mContext);
		
		i.setImageBitmap(picturesInfo.get(position).getThumbnail());

		i.setAdjustViewBounds(true);
		i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT));
		i.setBackgroundResource(R.drawable.picture_frame);
		return i;
	}
}